
#if !defined(AFX_IMGDIALOGBASE_H__91F69DFE_B533_4517_86FE_3DF31C518DB8__INCLUDED_)
#define AFX_IMGDIALOGBASE_H__91F69DFE_B533_4517_86FE_3DF31C518DB8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ImgDialogBase.h : header file
//
#pragma warning(disable:4786)
#include <map>


class CImgDialogBase;

typedef struct _tagCtrlInfo
{
	WNDPROC				pWndProc;
	CImgDialogBase *	pImgDlg;
} tagCtrlInfo, *LPCtrlInfo;

//typedef struct tagGUITHREADINFO
//{
//    DWORD   cbSize;
//    DWORD   flags;
//    HWND    hwndActive;
//    HWND    hwndFocus;
//    HWND    hwndCapture;
//    HWND    hwndMenuOwner;
//    HWND    hwndMoveSize;
//    HWND    hwndCaret;
//    RECT    rcCaret;
//} GUITHREADINFO, *PGUITHREADINFO;

typedef BOOL(WINAPI *PFN_SetLayeredWindowAttributes)(
											HWND hwnd,
											COLORREF crKey,
											BYTE bAlpha,
											DWORD dwFlags);

typedef BOOL(WINAPI *PFN_UpdateLayeredWindow)( 
											HWND hWnd,
											HDC hdcDst,
											POINT *pptDst,
											SIZE *psize,
											HDC hdcSrc,
											POINT *pptSrc,
											COLORREF crKey,
											BLENDFUNCTION *pblend,
											DWORD dwFlags);

typedef BOOL (WINAPI *PFN_GetGUIThreadInfo)( 
											DWORD idThread,
											PGUITHREADINFO pgui);

/////////////////////////////////////////////////////////////////////////////
// CImgDialogBase dialog

class CImgDialogBase : public CDialog
{
// Construction
public:
	CImgDialogBase( UINT nIDD
		, LPCWSTR lpszFile
		, CWnd* pParent = NULL
		);
	
	CImgDialogBase( UINT nIDD
		, UINT nImgID
		, LPCTSTR lpszType
		, HINSTANCE hResourceModule = NULL
		, CWnd* pParent = NULL
		);   // standard constructor

	virtual ~CImgDialogBase();
// Dialog Data
	//{{AFX_DATA(CImgDialogBase)
	//enum { IDD = _UNKNOWN_RESOURCE_ID_ };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CImgDialogBase)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CImgDialogBase)
	virtual BOOL OnInitDialog();
	virtual void PostNcDestroy();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnMove(int x, int y);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

private:
	CString						m_strWndClassName;
	HWND						m_hFakeWnd;
	BOOL						m_bIsRefreshing;
	int							m_nAlpha;
	Image *						m_pImage;
	BOOL						m_bShown;

	void DestoryFakeWnd(void);
	void CreateFakeWnd(void);
	void HookControlUpdate(HWND hWnd);
	void UnhookControlUpdate(HWND hWnd);
	void Refresh(void);
	void DrawCtrl( Graphics & graphics, HDC hDC, HWND hWnd);
	void DrawCaret(Graphics & graph);


	static PFN_SetLayeredWindowAttributes s_pfnSetLayeredWindowAttributes;
	static PFN_UpdateLayeredWindow s_pfnUpdateLayeredWindow;
	static PFN_GetGUIThreadInfo s_pfnGetGUIThreadInfo;
	static std::map<HWND, tagCtrlInfo>	s_mpCtrl;
	static LRESULT CALLBACK CtrlWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam);
	static UINT __cdecl ShowMotionThread( LPVOID pParam );
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_IMGDIALOGBASE_H__91F69DFE_B533_4517_86FE_3DF31C518DB8__INCLUDED_)
